-
Notifications
You must be signed in to change notification settings - Fork 0
Add generateStaticParams and generateMetadata to fix Next.js build failure #86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add generateStaticParams and generateMetadata to fix Next.js build failure #86
Conversation
- Add generateStaticParams function to export static params for all doc pages - Add generateMetadata function to properly generate page metadata - Change dynamicParams from true to false and remove 'force-dynamic' - Update Next.js from 15.1.6 to 15.3.0 to match fumadocs-mdx peer dependencies - Add root meta.json for docs navigation structure - Add description rendering in page component These changes address the build error "Failed to collect configuration" by ensuring Next.js has the required functions for static generation. Co-authored-by: huangyiirene <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR addresses Next.js build failures by implementing proper static generation for the fumadocs documentation site. The changes convert the dynamic catch-all route to static generation by adding required functions and updating dependencies.
Changes:
- Added
generateStaticParams()andgenerateMetadata()functions to enable static page generation - Updated Next.js from version 15.1.6 to 15.3.0 to match fumadocs-mdx peer dependency requirements
- Added
meta.jsonconfiguration file to define documentation navigation structure - Enhanced page component to display document descriptions
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| apps/site/app/docs/[[...slug]]/page.tsx | Added static generation functions (generateStaticParams, generateMetadata), switched from dynamic to static rendering, and added description display |
| apps/site/package.json | Updated Next.js dependency from ^15.1.6 to ^15.3.0 |
| pnpm-lock.yaml | Updated lockfile to reflect Next.js version change (resolves to 15.5.9) |
| apps/site/content/docs/meta.json | Added navigation structure configuration for documentation pages |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
| } catch (error) { | ||
| console.error('Error in generateMetadata:', error); | ||
| return {}; |
Copilot
AI
Jan 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error handling in generateMetadata silently swallows all errors by logging to console and returning an empty metadata object. This could hide important issues during the build process. Consider removing the try-catch wrapper since Next.js will handle errors appropriately during static generation, or at minimum, re-throw the error after logging it so the build fails with a clear error message.
| if (!page) { | ||
| return {}; |
Copilot
AI
Jan 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is inconsistent error handling between generateMetadata and the Page component. In generateMetadata (line 18-19), when a page is not found, an empty metadata object is returned. However, in the Page component (line 37), the same condition triggers a notFound() call which returns a 404. This inconsistency means pages will be generated with empty metadata even though they don't exist. Consider calling notFound() in generateMetadata when page is null to maintain consistency.
| "fumadocs-ui": "^15.0.0", | ||
| "lucide-react": "^0.344.0", | ||
| "next": "^15.1.6", | ||
| "next": "^15.3.0", |
Copilot
AI
Jan 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Next.js version specifier change from ^15.1.6 to ^15.3.0 allows the package manager to install version 15.5.9 (as shown in pnpm-lock.yaml line 86). While this may work, there's a risk of compatibility issues with the [email protected] package. The PR description mentions fumadocs-mdx requires Next.js 15.3.0 as a peer dependency, but the actual resolved version is 15.5.9. Consider pinning to a more specific version range (e.g., "^15.3.0 <15.4.0") or testing with the exact peer dependency version to ensure compatibility.
| "next": "^15.3.0", | |
| "next": "15.3.0", |
CI build was failing during page data collection phase with
TypeError: Cannot read properties of undefined (reading 'map')in the fumadocs documentation site.Changes
generateStaticParams()- Next.js requires this for catch-all routes[[...slug]]to determine which pages to statically generategenerateMetadata()- Required for metadata generation during build; includes error handling for missing pagesdynamicParamstofalseand removeddynamic = 'force-dynamic'meta.json- Defines navigation structure for docs atcontent/docs/meta.jsonNote
Build still fails at same point. Root cause appears to be fumadocs-mdx 14.x / fumadocs-core 15.x compatibility issue or missing async mode configuration. These changes are necessary prerequisites but may not be sufficient.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.